package com.saber.bean;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 *
 * @author sihai
 *
 */
public class Report extends AbstractDO {

	/**
	 *
	 */
	private static final long serialVersionUID = 5853924452500194277L;

	/**
	 * 1小时
	 */
	public static final long DEFAULT_REPORT_PERIOD = 1000 * 60 * 60;

	/**
	 * 7天
	 */
	public static final long WEEK_REPORT_PERIOD = 1000 * 60 * 60 * 24 * 7;

	/**
	 * 5分钟一个点
	 */
	public static final long DEFAULT_REPORT_ITEM_PERIOD = 1000 * 60 * 5;

	/**
	 * 20秒一个点
	 */
	public static final long REALTIME_REPORT_ITEM_PERIOD = 1000 * 20;

	/**
	 *
	 * @author sihai
	 *
	 */
	public static enum ReportName {

		/**
		 *
		 */
		KPI,

		/**
		 *
		 */
		HTTP_Response_Code_Report,

		/**
		 *
		 */
		HTTP_Request_Client_IP_Report,

		/**
		 *
		 */
		HTTP_REQUEST_CLIENT_IP_WINDOW_REPORT,

		/**
		 *
		 */
		SERVICE_RESPONSE_TIME_REPORT,

		/**
		 *
		 */
		Service_Network_TX_Report,

		/**
		 *
		 */
		Service_Network_IN_TX_Report,

		/**
		 *
		 */
		Service_Network_OUT_TX_Report,

		/**
		 *qxw_add
		 */
		Service_Network_Current_OUT_TX_Report,

		/**
		 *qxw_add
		 */
		Service_Network_Current_OUT_TX_HTTP_Report,

		/**
		 *
		 */
		Service_QPS_Report,

		/**
		 *qxw_add
		 */
		Service_Current_QPS_Report,

		/**
		 *qxw_add
		 */
		Service_Current_QPS_Response_Report,

		/**
		 *
		 */
		Service_Connection_Report,


		/**
		 * qxw_add
		 */
		Service_Realtime_Connection_Report,

		/**
		 * qxw_add
		 */
		Service_Week_Connection_Report,

		/**
		 * qxw_add
		 */
		Service_Realtime_Traffic_Report,

		/**
		 * qxw_add
		 */
		Service_Week_Traffic_Report,

		/**
		 *
		 */
		SERVICE_CURRENT_CONNECTION_REPORT,

		/**
		 *
		 */
		SERVICE_CONNECTION_CITY_REPORT,

		/**
		 *
		 */
		SERVICE_CONNECTION_CLIENT_IP_WINDOW_REPORT,

		/**
		 *
		 */
		SERVICE_REQUEST_CLIENT_IP_WINDOW_REPORT,

		/**
		 *
		 */
		SERVICE_TRAFFIC_CLIENT_IP_WINDOW_REPORT,

		/**
		 *
		 */
		APP_SERVICE_NETWORK_TOPOLOGY_REPORT,

		/**
		 *
		 */
		SERVICE_HOST_NETWORK_TOPOLOGY_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_HEAP_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_HEAP_MAX_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_HEAP_USED_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_HEAP_COMMITED_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_OTHER_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_OTHER_PERMGEN_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_OTHER_CODE_CACHE_REPORT,

		/**
		 *
		 */
		JVM_MMEORY_GC_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_YOUNG_GC_REPORT,

		/**
		 *
		 */
		JVM_MEMORY_FULL_GC_REPORT,

		/**
		 *
		 */
		JVM_THREAD_REPORT;
	}

	//
	public static enum ReportItemName {

		// KPI
		request_total,

		error_total,

		in_tx_total,

		out_tx_total,

		request_qps,

		error_qps,

		in_tx_speed,

		out_tx_speed,

		current_connection,

		//
	}

	/**
	 *
	 * @author sihai
	 *
	 */
	public static enum SourceType {

		/**
		 *
		 */
		USER,

		/**
		 *
		 */
		APP,

		/**
		 *
		 */
		SERVICE,

		/**
		 *
		 */
		HOST;
	}


	/**
	 *
	 * @author ZhuHuaPing
	 *
	 */
	public static enum CountryType {
		/**
		 *
		 */
		ABROAD("0", "国外"),

		/**
		 *
		 */
		DOMESTIC("1", "国内"),

		/**
		 *
		 */
		UNKNOWN("2", "未知地");

		private final String key;
		private final String title;

		/**
		 *
		 * @param key
		 * @param title
		 */
		private CountryType(String key, String title) {
			this.key = key;
			this.title = title;
		}

		/**
		 *'0'：'国外'；'1'：'国内'；'2'：'未知地'
		 * @return '0'；'1'；'2'
		 */
		public String getKey() {
			return key;
		}

		/**
		 *'0'：'国外'；'1'：'国内'；'2'：'未知地'
		 * @return '国外'；'国内'；'未知地'
		 */
		public String getTitle() {
			return title;
		}
	}

	/**
	 *
	 */
	private Long source;

	/**
	 *
	 */
	private SourceType sourceType;

	/**
	 *
	 */
	private String name;

	/**
	 *
	 */
	private String countryType;

	/**
	 *
	 */
	private Date startTime;

	/**
	 *
	 */
	private Date endTime;

	/**
	 *
	 */
	private List<ReportItem> itemList;

	/**
	 *
	 */
	private List<ReportItem> inItemList;

	/**
	 *
	 */
	private List<ReportItem> outItemList;

	/**
	 *
	 */
	private List<Long> idList;

	/**
	 *
	 */
	private Object sourceObject;

	public Long getSource() {
		return source;
	}

	public void setSource(Long source) {
		this.source = source;
	}

	public SourceType getSourceType() {
		return sourceType;
	}

	public void setSourceType(SourceType sourceType) {
		this.sourceType = sourceType;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCountryType() {
		return countryType;
	}

	public void setCountryType(String countryType) {
		this.countryType = countryType;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public List<ReportItem> getItemList() {
		return itemList;
	}

	public void setItemList(List<ReportItem> itemList) {
		this.itemList = itemList;
	}

	public List<ReportItem> getInItemList() {
		return inItemList;
	}

	public void setInItemList(List<ReportItem> inItemList) {
		this.inItemList = inItemList;
	}

	public List<ReportItem> getOutItemList() {
		return outItemList;
	}

	public void setOutItemList(List<ReportItem> outItemList) {
		this.outItemList = outItemList;
	}

	public List<Long> getIdList() {
		return idList;
	}

	public void setIdList(List<Long> idList) {
		this.idList = idList;
	}

	public Object getSourceObject() {
		return sourceObject;
	}

	public void setSourceObject(Object sourceObject) {
		this.sourceObject = sourceObject;
	}

	public void addReportItem(ReportItem reportItem) {
		if(null == this.itemList) {
			this.itemList = new ArrayList<ReportItem>();
		}
		this.itemList.add(reportItem);
	}
}